package com.lxg.service.adminService.impl;

import com.lxg.dao.BooksDao;
import com.lxg.service.adminService.AdminBooksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminBooksServiceImpl implements AdminBooksService {
    @Autowired
    BooksDao booksDao;

    /**
     * 添加一本图书
     * @param name
     * @param author
     * @param num
     * @param remainder
     * @param press
     * @param address
     */
    @Override
    public boolean addBook(String name, String author, Integer num, Integer remainder,
                        String press, String address) {
        booksDao.addBook(name, author, num, remainder, press, address);
        return true;
    }


    /**
     * 管理员根据bid删除一本书
     * @param bid
     */
    @Override
    public boolean deleteBookByBid(Integer bid) {
        booksDao.deleteBookByBid(bid);
        return true;
    }




    @Override
    public Integer getTypeNumber() {
        Integer booksTypeNum = booksDao.getBooksTypeNum();
        return booksTypeNum;
    }

    @Override
    public Integer getAllNum() {
        Integer booksNum = booksDao.getBooksNum();
        return booksNum;
    }

    @Override
    public Integer getBorrowNum() {
        Integer borrowedBooksNum = booksDao.getBorrowedBooksNum();
        return borrowedBooksNum;
    }

    @Override
    public boolean adminUpdateBook(Integer bid,String name,Integer num,Integer remainder,String author,String address,String press) {
        booksDao.updateBook(bid, name, num, remainder, author, address, press);
        return true;
    }
}
